/*
 * MiSans Light Theme for Typora
 * 基于澎湃OS设计风格的明亮模式主题
 * 融合小米设计语言，提供舒适的写作体验
 */

/* 引入MiSans字体 */
@font-face {
  font-family: 'MiSans';
  font-weight: 300;
  font-style: normal;
  src: url('./misans/MiSans-Light.woff2') format('woff2');
}

@font-face {
  font-family: 'MiSans';
  font-weight: 400;
  font-style: normal;
  src: url('./misans/MiSans-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'MiSans';
  font-weight: 500;
  font-style: normal;
  src: url('./misans/MiSans-Medium.woff2') format('woff2');
}

@font-face {
  font-family: 'MiSans';
  font-weight: 600;
  font-style: normal;
  src: url('./misans/MiSans-Semibold.woff2') format('woff2');
}

@font-face {
  font-family: 'MiSans';
  font-weight: 700;
  font-style: normal;
  src: url('./misans/MiSans-Bold.woff2') format('woff2');
}

/* 澎湃OS风格颜色系统 - 明亮模式 */
:root {
  /* 基础颜色 */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f7;
  --bg-tertiary: #eeeeee;
  
  /* 文字颜色 */
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  
  /* 边框颜色 */
  --border-primary: #e0e0e0;
  --border-secondary: #f0f0f0;
  
  /* 强调色 */
  --accent-color: #ff6700;
  --accent-light: rgba(255, 103, 0, 0.15);
  
  /* 功能色 */
  --success-color: #4cd964;
  --warning-color: #ff9500;
  --error-color: #ff3b30;
  --info-color: #007aff;
  
  /* 选中文本颜色 */
  --selection-bg: rgba(255, 103, 0, 0.5);
  --selection-text: #000000;
  
  /* Typora 特定变量 */
  --sidebar-bg-color: var(--bg-secondary);
  --window-border: var(--border-primary);
  --item-hover-bg-color: var(--bg-tertiary);
  --primary-color: var(--accent-color);
  --primary-light: var(--accent-light);
  --menu-bg-color: var(--bg-primary);
}

/* 基础样式 */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'MiSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 全局选中文本样式 */
::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

/* Typora 编辑器特定的选中文本样式 */
#write ::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

#write ::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

/* 标题样式 */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 2.2em;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.3em;
}

h2 {
  font-size: 1.8em;
  border-bottom: 2px solid var(--border-primary);
  padding-bottom: 0.3em;
}

h3 {
  font-size: 1.5em;
}

h4 {
  font-size: 1.3em;
}

h5 {
  font-size: 1.1em;
}

h6 {
  font-size: 1em;
  color: var(--text-secondary);
}

/* 段落样式 */
p {
  margin: 1em 0;
  text-align: justify;
}

/* 链接样式 */
a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #ff8a3c;
  text-decoration: underline;
}

/* 代码块样式 */
pre, code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background-color: var(--bg-secondary);
  border-radius: 4px;
  font-size: 0.9em;
}

code {
  padding: 0.2em 0.4em;
  color: #e91e63;
}

pre {
  padding: 1em;
  overflow-x: auto;
  border: 1px solid var(--border-primary);
  margin: 1.5em 0;
}

pre code {
  padding: 0;
  background-color: transparent;
  border: none;
}

/* 代码块中的选中文本样式 */
pre ::selection,
code ::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
  opacity: 0.9;
}

pre ::-moz-selection,
code ::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
  opacity: 0.9;
}

/* 引用样式 */
blockquote {
  border-left: 4px solid var(--accent-color);
  margin: 1.5em 0;
  padding: 0.5em 1em;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-style: italic;
}

/* 列表样式 */
ul, ol {
  margin: 1em 0;
  padding-left: 1.5em;
}

li {
  margin: 0.5em 0;
}

/* 表格样式 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  overflow-x: auto;
  display: block;
}

table th, table td {
  padding: 0.75em;
  border: 1px solid var(--border-primary);
  text-align: left;
}

table th {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

table tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

table tr:hover {
  background-color: var(--bg-tertiary);
}

/* 侧边栏样式 */
.sidebar-content {
  background-color: var(--sidebar-bg-color) !important;
  border-right: 1px solid var(--window-border) !important;
}

/* 任务列表 */
task-list-item {
  list-style-type: none;
}

.task-list-item input {
  margin-right: 0.5em;
  vertical-align: middle;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background-color: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background-color: var(--border-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-tertiary);
}

/* Typora 主题特定样式 */
#write {
  max-width: 900px;
  margin: 0 auto;
  padding: 2em;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

#write > h1:first-child,
#write > h2:first-child,
#write > h3:first-child,
#write > h4:first-child,
#write > h5:first-child,
#write > h6:first-child {
  margin-top: 0;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
  #write {
    padding: 1.5em 1em;
  }
  
  h1 {
    font-size: 1.8em;
  }
  
  h2 {
    font-size: 1.5em;
  }
  
  h3 {
    font-size: 1.3em;
  }
}

/* Typora 右键菜单样式 */
.context-menu {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-primary) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.context-menu .menu-item {
  color: var(--text-primary) !important;
  background-color: transparent !important;
  transition: all 0.2s ease !important;
  padding: 6px 16px !important;
  margin: 0 !important;
  outline: none !important;
  border: none !important;
}

.context-menu .menu-item:hover,
.context-menu .menu-item.hover {
  background-color: #ff6700 !important;
  color: #ffffff !important;
  transform: translateX(2px) !important;
  font-weight: 500 !important;
}

.context-menu .menu-item:active,
.context-menu .menu-item.selected {
  background-color: #ff6700 !important;
  color: #ffffff !important;
}

.context-menu .menu-item.disabled,
.context-menu .menu-item:disabled {
  color: var(--text-secondary) !important;
  background-color: transparent !important;
}

.context-menu .menu-item.disabled:hover,
.context-menu .menu-item:disabled:hover {
  background-color: transparent !important;
  transform: none !important;
  cursor: not-allowed !important;
}

.context-menu .menu-divider {
  background-color: var(--border-primary) !important;
  height: 1px !important;
  margin: 4px 0 !important;
}

/* 同时兼容旧版选择器 */
.context-menu .context-menu-item {
  color: var(--text-primary) !important;
  background-color: transparent !important;
  transition: all 0.2s ease !important;
  padding: 6px 16px !important;
  margin: 0 !important;
  outline: none !important;
  border: none !important;
}

.context-menu .context-menu-item:hover,
.context-menu .context-menu-item.hover {
  background-color: #ff6700 !important;
  color: #ffffff !important;
  transform: translateX(2px) !important;
  font-weight: 500 !important;
}

.context-menu .context-menu-item.context-menu-item-active,
.context-menu .context-menu-item:active {
  background-color: #ff6700 !important;
  color: #ffffff !important;
}

.context-menu .context-menu-item.context-menu-item-disabled,
.context-menu .context-menu-item:disabled {
  color: var(--text-secondary) !important;
  background-color: transparent !important;
}

.context-menu .context-menu-item.context-menu-item-disabled:hover,
.context-menu .context-menu-item:disabled:hover {
  background-color: transparent !important;
  transform: none !important;
  cursor: not-allowed !important;
}

.context-menu .context-menu-divider {
  background-color: var(--border-primary) !important;
  height: 1px !important;
  margin: 4px 0 !important;
}

/* 编辑区域内右键菜单样式 */
#write + .context-menu {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

#write + .context-menu .menu-item,
#write + .context-menu .context-menu-item {
  color: var(--text-primary) !important;
}

#write + .context-menu .menu-item:hover,
#write + .context-menu .menu-item.hover,
#write + .context-menu .context-menu-item:hover,
#write + .context-menu .context-menu-item.hover {
  background-color: #ff6700 !important;
  color: #ffffff !important;
  transform: translateX(2px) !important;
  font-weight: 500 !important;
}

#write + .context-menu .menu-item.selected,
#write + .context-menu .menu-item:active,
#write + .context-menu .context-menu-item.context-menu-item-active,
#write + .context-menu .context-menu-item:active {
  background-color: #ff6700 !important;
  color: #ffffff !important;
}

/* 强制应用样式，覆盖Typora默认样式 */
body .context-menu,
html .context-menu,
* .context-menu {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

body .context-menu .menu-item,
html .context-menu .menu-item,
* .context-menu .menu-item,
body .context-menu .context-menu-item,
html .context-menu .context-menu-item,
* .context-menu .context-menu-item {
  color: var(--text-primary) !important;
}

body .context-menu .menu-item:hover,
html .context-menu .menu-item:hover,
* .context-menu .menu-item:hover,
body .context-menu .menu-item.hover,
html .context-menu .menu-item.hover,
* .context-menu .menu-item.hover,
body .context-menu .context-menu-item:hover,
html .context-menu .context-menu-item:hover,
* .context-menu .context-menu-item:hover,
body .context-menu .context-menu-item.hover,
html .context-menu .context-menu-item.hover,
* .context-menu .context-menu-item.hover {
  background-color: #ff6700 !important;
  color: #ffffff !important;
  transform: translateX(2px) !important;
  font-weight: 500 !important;
  position: relative !important;
  z-index: 9999 !important;
}